我学院:Unity控制输入系统 |
您所在的位置:网站首页 › unity 登录系统 › 我学院:Unity控制输入系统 |
学游戏,就上我学院!
www.woxueyuan.com
控制输入系统
- Input 类实例讲解
做游戏少不了控制, 但是一个成熟的游戏引擎, 是不能简单仅仅获取键盘中或者遥感确 定的按键来控制, 要考虑到用户更改游戏按键的情况, 当然也得考虑到不同设备的不通输入 方式,比如 U3D 是可以运行在 iphone 上的, iphone 可没有键盘和上下左右键,他有平衡控 制(简单化解为水平和垂直两个方向度数), 如果用户使用飞行或者汽车方向盘手柄, 那就 不能简单用一个按键来描述了, 需要有一个度数的问题 (也可以简单分解为水平和垂直两个 方向度数)。
U3D 提供了一个 Input 类封装控制输入,不做详细解释,在后面我会举一些常用的例子 来说明。
Class Variables mousePositionThe current mouse position in pixel coordinates. (Read Only) anyKeyIs any key or mouse button currently held down? (Read Only) anyKeyDownReturns true the first frame the user hits any key or mouse button (Read Only). inputStringReturns the keyboard input entered this frame (Read Only). Class Functions GetAxisReturns the value of the virtual axis identified by axisName. GetAxisRawReturns the value of the virtual axis identified by axisName with no smoothing filtering applied. GetButtonReturns true while the virtual button identified by buttonName is held down. GetButtonDownReturns true during the frame the user pressed down the virtual button identified by buttonName. GetButtonUpReturns true the first frame the user releases the virtual button identified by buttonName. GetKeyReturns true while the user holds down the key identified by name. Think auto fire. GetKeyDownReturns true during the frame the user starts pressing down the key identified by name. GetKeyUpReturns true during the frame the user releases the key identified by name. GetMouseButtonReturns whether the the given mouse button is held down. GetMouseButtonDownReturns true during the frame the user pressed the given mouse button. GetMouseButtonUpReturns true during the frame the user releases the given mouse button. ResetInputAxesResets all input. After ResetInputAxes all axes return to 0 and all buttons return to 0 for one frame.
获取键盘某一 ( 这里是空格键 ) 按键状态 (bool) : Input.GetKeyDown(KeyCode.Space) 这 |
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |